package com.itheima.dubbo.mysql.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itheima.commons.model.domain.Admin;
import com.itheima.dubbo.mysql.mapper.SystemUserMapper;
import com.itheima.dubbo.interfaces.SystemUserApi;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Auther: alongchan
 * @Date: 2021/12/16 21:00
 * @Description:
 */
@Service
public class SystemUserApiImpl implements SystemUserApi {
    @Autowired
    private SystemUserMapper systemUserMapper;

    //查询管理人员用户
    @Override
    public Admin findAdmin(String username, String password) {
        Admin admin = systemUserMapper.selectOne(Wrappers.lambdaQuery(Admin.class).eq(Admin::getPassword, password).eq(Admin::getUsername, username));
        return admin;
    }

    //通过uid查询管理员
    @Override
    public Admin findAdminByAdminId(Long userId) {
        return systemUserMapper.selectOne(Wrappers.lambdaQuery(Admin.class).eq(Admin::getUid, userId));
    }

}
